package com.bndg.browser.ui

import android.os.Bundle
import android.view.View
import android.widget.ImageView
import com.bndg.browser.R
import com.shuyu.gsyvideoplayer.GSYBaseActivityDetail
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer


class LocalVideoPlayActivity : GSYBaseActivityDetail<StandardGSYVideoPlayer>() {
    private var detailPlayer: StandardGSYVideoPlayer? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_local_video_play)
        detailPlayer = findViewById(R.id.detail_player);
        //增加title
        detailPlayer?.titleTextView?.visibility = View.GONE;
        detailPlayer?.backButton?.visibility = View.GONE;

        initVideoBuilderMode();
    }

    fun initView() {
    }

    fun initData() {
        // 创建 ExoPlayer 实例
    }

    override fun onPause() {
        super.onPause()
    }

    override fun onStop() {
        super.onStop()
    }

    override fun getGSYVideoPlayer(): StandardGSYVideoPlayer {
        return detailPlayer!!
    }

    override fun getGSYVideoOptionBuilder(): GSYVideoOptionBuilder {
        val url = intent.getStringExtra(VIDEO_URL) ?: ""
        //内置封面可参考SampleCoverVideo
        val imageView = ImageView(this)
        return GSYVideoOptionBuilder()
            .setThumbImageView(imageView)
            .setUrl(url)
            .setCacheWithPlay(true)
            .setVideoTitle(" ")
            .setIsTouchWiget(true)
            .setRotateViewAuto(false)
            .setLockLand(false)
            .setShowFullAnimation(false)
            .setNeedLockFull(true)
            .setSeekRatio(1f)
    }

    override fun clickForFullScreen() {
    }

    override fun getDetailOrientationRotateAuto(): Boolean {
        return true
    }

    companion object {
        val VIDEO_URL = "VideoUrl"
    }
}
